﻿/*!	@file	r_gui_server.h
	@brief	GUI制御用
Copyright (c) 2010 Yuya Yamaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _R_DEBUG_SERVER_H_
#define _R_DEBUG_SERVER_H_

#include "../rtti/r_rtti_class_base.h"
#include "../util/r_util_singleton.h"
#include <vector>
#include "../alloc/r_alloc_new_delete.h"
#include "../alloc/r_alloc_allocator.h"

#include "r_gui_widget.h"
#include "r_gui_event.h"
#include "r_gui_drawinfo.h"

namespace r{
	namespace gui{
		namespace draw{
			class Draw;
		}
	}
}

namespace r{
	namespace gui{

		//! GUIサーバ
		/*!
		*/
		class Server : public r::rtti::ClassBase
		{
			RRTTI_REFLECTION_DECLARE
			RSINGLETONTGET_DECLARE ( Server )
			RALLOC_PLACEMENT_NEW_DELETE_DECLEARE
		protected:
			//! コンストラクタ
			/*!
			*/
			Server();
			//! デストラクタ
			/*!
			*/
			virtual	~Server();
		public:
			// システム呼び出し
			//! 更新処理
			/*!
			*/
			void				update();
			//! 描画処理
			/*!
			*/
			void				draw();
		public:
			//! 子のGUIを削除する
			/*!
			*/
			void				remove ( Widget*	widget );
			//! 親子関係を変更する
			/*!
			@param	child		[io]	親子関係を解除する子のGUI
			@param	newParent	[io]	新しい親のGUI,NULL指定でGUIの階層から外れます
			*/
			void				unParent ( Widget*	child, Widget*	newParent );
			///
			/*!
			*/
			void				addChild ( Widget*	child );
			//! GUI描画インターフェースを取得する
			/*!
			*/
			draw::Draw*			getGUIDraw() const;
		public:
			//! 描画情報の取得
			/*!
			*/
			const	DrawInfo&	getDrawInfo() const;
		protected:
		private:
			Event			eventData;
			//! 削除リスト
			Widget_array	removeWidgets;
			//! ペアレントリスト
			Widget_array	parentWidgets;
			//! アクティブGUI
			Widget_array	widgets;
			///
			draw::Draw*		guiDraw;
			///
			DrawInfo		guiDrawInfo;
		};
	}
}


#endif // _R_DEBUG_SERVER_H_

